<template>
  <div class="user_share_records">
    <el-container>
      <el-header>
        <header-item :item="tips"></header-item>
      </el-header>
      <el-main>
        <main-tools-item :toolsType="toolsType" @add='add'></main-tools-item>
        <main-spare-item @onClick=''></main-spare-item>
        <main-data-list-item :columns="columns" :dataList="dataList" :pager="page" @batchDelete='batchDelete' @currentChange='currentChange'>
        </main-data-list-item>
      </el-main>
    </el-container>
  </div>
</template>

<script>
  import {
    get,
    post,
    pat,
    del,
    common,
    getRefresh
  } from "../../../../api/api";
  import headerItem from "./../../Commons/headerItem.vue";
  import mainToolsItem from "./../../Commons/mainToolsItem.vue";
  import mainSpareItem from "./../../Commons/mainSpareItem.vue";
  import mainDataListItem from "./../../Commons/mainDataListItem.vue";
  export default {
    components: {
      headerItem,
      mainToolsItem,
      mainSpareItem,
      mainDataListItem
    },
    data() {
      return {
        tips: "商品分享记录",
        toolsType: 2,
        sels: [],
        page: {
          pageNo: 1,
          limit: 10,
          sizes: [10, 50, 100],
          total: 0
        },
        columns: [{
            prop: 'id',
            label: 'id',
            width: '150',
            align: 'center'
          },
          {
            prop: 'username',
            label: '姓名',
            width: '200',
            align: 'center',
            // formatter: this.formatter
          },
          {
            prop: 'created_at',
            label: '创建时间',
            width: '',
            align: 'center'
          },
          {
            prop: 'updated_at',
            label: '更新时间',
            width: '',
            align: 'center'
          }
        ],
        dataList: [{
            id: 1,
            username: 'user_share_records_xxy',
            created_at: "2019-03-01",
            updated_at: "2018-05-03"
          },
          {
            id: 2,
            username: 'user_share_records_xxy',
            created_at: "2019-03-01",
            updated_at: "2018-05-03"
          },
          {
            id: 3,
            username: 'user_share_records_xxy',
            created_at: "2019-03-01",
            updated_at: "2018-05-03"
          }
        ],
        addDialogVisible: false,
        addForm: {},
        editDialogVisible:false,
        editForm: {},
      };
    },
    methods: {
      //--------新增----------
      add() {
        this.addDialogVisible = true;
      },
      addSumbit() {
        this.addDialogVisible =false;
      },
      //--------编辑----------
      sysroleHandleEdit() {
        this.editDialogVisible = true;
      },
      editSumbit(){
        this.editDialogVisible = false;
      },
      //--------删除----------
      sysroleHandleDelete() {},
      batchDelete(val){
        console.log(val);
      },
      //-------分页----------
      currentChange(val){
        console.log(val);
      },
      //获取list列表
      getGroupList() {
        return new Promise((resolve, reject) => {
          get("/sys/groups").then(resdata => {
            let self = function () {
              getRefresh(this.getGroupList);
            }.bind(this);
            let error = function () {
              alert(resdata.msg)
            }.bind(this);
            let success = function () {
              if (resdata.code == 0) {

              }
            }.bind(this);
            common(self)(error)(success)(resdata);
            resolve();
          });
        });
      },
    },
    async mounted() {
      // await this.$store.dispatch("userInfo", this);
      // await this.getGroupList();
      // await this.getChangeGroupList();
      // setTimeout(() => {}, 1000);
    },
    watch: {
      // filterText(val) {
      //   this.$refs.tree2.filter(val);
      // }
    }
  };

</script>

<style lang="scss">
  .user_share_records {
    background-color: white;
    font-size: 1.8rem;
    width: 100%;
    height: 100%;
    .el-container {
      height: 100%;
      .el-header,
      .el-footer {
        background-color: #F9FAFE;
        color: #333;
        text-align: center;
        line-height: 50px;
        height: 50px !important;
        .header-child {
          height: 50px;
          width: 100%;
          text-align: left;
          padding-left: 20px;
          background-color: #cbe9eb;
          border-bottom: 1px solid black;
          box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
        } 
      }
      .el-main {
        box-shadow: 0 5px 5px 0px rgba(0, 0, 0, 0.5); // margin: 10px 20px;
        margin: 10px;
        background-color: #fff;
        color: #333;
        text-align: center;
        height: 100%;
      }
    }
  }

</style>
